package com.songjiakang.controller;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;
import com.songjiakang.entity.Home;
import com.songjiakang.service.HomeService;

@Controller
public class HomeController {
	@Autowired
	private HomeService service;
	//列表
	@RequestMapping("list")
	public String list(Model model,Home home,@RequestParam(defaultValue="1")Integer pageNum,@RequestParam(defaultValue="3")Integer pageSize){
		PageInfo info=service.list(pageNum,pageSize,home);
		model.addAttribute("info", info);
		System.out.println(info);
		return "list";
	}
	//删除
	@RequestMapping("del")
	@ResponseBody
	public boolean del(Integer id){
		Boolean del=service.del(id);
		return del;
	}
	//退租
	@RequestMapping("tui")
	public String tui(Integer id){
		service.tui(id);
		return "redirect:/list";
	}
	//出租
		@RequestMapping("chu")
		public String chu(Integer id){
			service.chu(id);
			return "redirect:/list";
		}
}
